home *** CD-ROM | disk | FTP | other *** search
- /*************************************************************************
- * Copyright (c) 1989-1992 Stone Design Corp. All rights reserved.
- * programmer: Bill Bumgarner
- * File name: SD_Depth_tx.sl
- * Date: Jul 21 1992
- * Purpose: Map a texture to a surface with depth cue style
- light response. Based on txtplastic, but allows
- one to specify the number of times to repeat the
- texture across the surface. Also used as a base for
- a series of other texture mapping shaders.
- *
- Variables:
- Ka: percentage of ambient light used
- Kd: percentage of diffuse light used
- Ks: specular highlight intensity
- roughness: the roughness/smoothness (reflectivity) of
- of the surface-- very noticeable effect on the
- specular highlight
- specularcolor: color used in the specular highlight
-
- s_frequency: # of times to repeat texture in the s direction
- t_frequency: # of times to repeat texture in the t direction
-
- txmap: full path to the texture map file
- ***************************************************************************/
-
- surface SD_Depth_tx(
- float Ka = 1,
- Kd = .5,
- Ks = .5,
- roughness = .1;
- color specularcolor = 1;
-
- float s_frequency = 1.,
- t_frequency = 1.;
-
- string txmap = "";
-
- )
- {
- point Nf = faceforward(N, I);
- float ss = s_frequency * s;
- float tt = t_frequency * t;
-
-
- if(txmap != ""){
- Ci = color texture(txmap, ss, tt);
- } else {
- Ci = Cs;
- }
- Oi=Os;
- Ci=Os * (Ci * (Ka*ambient() + Kd*diffuse(Nf)) +
- specularcolor * Ks * specular(Nf,-I,roughness));
- }